#pragma once

#include "ReadExtentAction.h"

#include "Classifier.h"
#include "OutputPin.h"

namespace uml {

ReadExtentAction::ReadExtentAction(const QString& umlType)
    : Action(umlType) {}

void ReadExtentAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Action::fromJson(json, errorList);
    classifier_ = JsonSerializable::create<Classifier>(json.value("classifier"), errorList);

    result_ = JsonSerializable::create<OutputPin>(json.value("result"), errorList);

}

void ReadExtentAction::toJson(QJsonObject& json) {
    Action::toJson(json);
    if (classifier_) {
        QJsonObject classifier_json;
        classifier_->toJson(classifier_json);
        json.insert("classifier", classifier_json);
    }
    if (result_) {
        QJsonObject result_json;
        result_->toJson(result_json);
        json.insert("result", result_json);
    }
}

/// <summary>
/// classifier getter
/// The Classifier whose instances are to be retrieved.
/// </summary>
shared_ptr<Classifier> ReadExtentAction::classifier() const {
    return classifier_;
}

/// <summary>
/// classifier setter
/// The Classifier whose instances are to be retrieved.
/// </summary>
void ReadExtentAction::setClassifier(shared_ptr<Classifier> value) {
    classifier_ = value;
}

/// <summary>
/// result getter
/// The OutputPin on which the Classifier instances are placed.
/// </summary>
shared_ptr<OutputPin> ReadExtentAction::result() const {
    return result_;
}

/// <summary>
/// result setter
/// The OutputPin on which the Classifier instances are placed.
/// </summary>
void ReadExtentAction::setResult(shared_ptr<OutputPin> value) {
    result_ = value;
}

} // namespace uml
